package com.granada.model.pc;

import com.granada.entity.Ao;
import com.granada.entity.Page;
import com.granada.entity.SysRolePermission;
import com.granada.model.common.RolePermission;
import com.granada.vo.req.RolePermissionOperationReqVO;
import com.granada.vo.resp.PageVO;
import com.granada.utils.MapperBeanUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public  class RolePermissionWithNeutral<T extends SysRolePermission,R extends RolePermissionOperationReqVO,F extends Page>  extends RolePermission<T,R,F> {

    public RolePermissionWithNeutral(T vo,R ro, F fo, Ao ao) {
        super(vo,ro,fo,ao);
    }
    @Override
    public Long addRolePermissionBefore() throws Exception {
        return null;
    }

    @Override
    public void addRolePermissionAfter() throws Exception {

    }

    @Override
    public void addBatchRolePermissionBefore() throws Exception {
        Date createTime=new Date();
        List<SysRolePermission> list=new ArrayList<>();
        for (Long permissionId:ro.getPermissionIds()){
            SysRolePermission sysRolePermission = SysRolePermission.builder()
                            .id(null)
                            .createTime(createTime)
                            .permissionId(permissionId)
                            .roleId(ro.getRoleId())
                    .build();
            list.add(sysRolePermission);
        }
        MapperBeanUtils.getSysRolePermissionMapper().removeByRoleId(ro.getRoleId());
        MapperBeanUtils.getSysRolePermissionMapper().batchRolePermission(list);
    }

    @Override
    public void addBatchRolePermissionAfter() throws Exception {

    }

    @Override
    public void updateRolePermissionBefore() throws Exception {
    }

    @Override
    public void updateRolePermissionAfter() throws Exception {
    }

    @Override
    public void deleteRolePermissionBefore() throws Exception {
    }

    @Override
    public void deleteRolePermissionAfter() throws Exception {
    }


    @Override
    public T getOne() throws Exception {
        return (T) MapperBeanUtils.getSysRolePermissionMapper().selectByPrimaryKey(ao.id);
    }

    @Override
    public T getSearchOne() throws Exception {
        return null;
    }

    @Override
    public List<T> getAll() throws Exception {
        return null;
    }

    @Override
    public List<T> getSearchAll() throws Exception {
        return null;
    }

    @Override
    public PageVO<T> getList() throws Exception {
        return null;
    }

    @Override
    public PageVO<T> getSearchList() throws Exception {
        return null;
    }



}
